package com.powernode.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.powernode.domain.IndexImg;
import com.powernode.domain.PickAddr;
import com.powernode.service.PickAddrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/shop/pickAddr")
@Api(tags = "自提点")
public class ShopPickAddrController {


    @Autowired
    private PickAddrService pickAddrService;


    @GetMapping("/page")
    @ApiOperation(value = "自提点管理分页")
    @PreAuthorize("hasAuthority('shop:pickAddr:page')")
    public ResponseEntity<Page<PickAddr>> PickAddrPage(Page<PickAddr> page, PickAddr pickAddr) {
        page = pickAddrService.pickAddrPage(page, pickAddr);
        return ResponseEntity.ok(page);
    }


    @PostMapping
    @ApiOperation(value = "自提点新增")
    @PreAuthorize("hasAuthority('shop:pickAddr:save')")
    public ResponseEntity<Void> addIndexImg(@RequestBody PickAddr pickAddr) {
        pickAddrService.save(pickAddr);
        return ResponseEntity.ok().build();
    }
}
